<template>
	<view class="add page c00">
		<view class="bgf7 p12">
			<view class="bgff px14 pb10">
				<view class="flex flexC borb py12" v-if="key == 'name'">
					<text class="flex1">{{value}}</text>
					<input class="py3 aliL" v-model="content" placeholder="请输入你要修改的内容" />
				</view>
				<view class="flex flexC borb py12" v-else>
					<text class="flex1">{{value}}</text>
					<input class="py3 aliL" type="digit" v-model="content" placeholder="请输入你要修改的内容" />
				</view>

			</view>

			<view class="flex flexC flexJC py20 ">
				<view class="aliC py12 w-17 bg41 r40" @click="update">保存</view>
			</view>


		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				key: '',
				value: '',
				content: '',
				room_id: '',

			};
		},
		onLoad(option) {
			this.key = option.key;
			this.value = option.value;
			this.content = option.content;
			this.room_id = option.room_id;


		},
		methods: {


			update() {

				let param = {};
				if (this.key == 'name') {
					param = {
						name: this.content,
						room_id: this.room_id
					};
				} else if (this.key == 'hour_price') {
					param = {
						hour_price: this.content,
						room_id: this.room_id
					};
				} else if (this.key == 'min_book_hour') {

					param = {
						min_book_hour: this.content,
						room_id: this.room_id

					};

				}else if (this.key == 'weigh') {

					param = {
						weigh: this.content,
						room_id: this.room_id

					};

				}else if (this.key == 'back_score') {

					param = {
						back_score: this.content,
						room_id: this.room_id

					};

				}else if (this.key == 'book_score') {

					param = {
						book_score: this.content,
						room_id: this.room_id

					};

				}

				if (this.content == '') {

					uni.showToast({
						title: "请输入您要修改的内容",
						icon: 'none'
					})
					return;
				}

				let that = this;
				this.$api.updateRoom(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						uni.navigateBack({
							delta: 1
						})
					} else {

					}
				})

			}
		}
	}
</script>

<style lang="scss" scoped>
	.add {
		.w48 {
			width: 96rpx;
			height: 96rpx;
		}

		.bottom {

			position: absolute;
			bottom: 20rpx;
		}

		.imgbox {
			width: 164rpx;
			height: 164rpx;
			background-color: #E8E8E8;
			position: relative;

			image {
				width: 100%;
				height: 100%;
			}

			.del {
				width: 36rpx;
				height: 36rpx;
				background: rgba(181, 180, 180, .8);
				position: absolute;
				top: -12rpx;
				right: -12rpx;
			}
		}
	}
</style>
